import pygame, random
from Goalkeeper import *
from Ball import *
from Stadium import *

class Handler:

	def __init__(self, screen, distance = 1):
		self.__distance = distance
		self.restart(screen)
		self.__redraw(screen)
		self.__gol = False

	def play(self, click_pos, screen):
		click_pos = (click_pos[0] + random.randint(0,10), click_pos[1] + random.randint(0,10))
		for element in self.__elements:
			element.set_destiny(click_pos)
	
		for i in range(self.__distance):
			self.__redraw(screen)
			pygame.time.delay(30)
			
		self.restart(screen)
		self.__redraw(screen)

	def __redraw(self, screen):
		for element in self.__elements:
			element.draw(screen)
		pygame.display.flip()

	def restart(self, screen):
		self.__elements = [Stadium(), Goalkeeper(screen, self.__distance), Ball(screen, self.__distance)]
	
	def wait(self):
		pass # do something?

